package com.mctuoluo.mappay;

import java.awt.Image;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.map.MinecraftFont;

public class Map
        extends MapRenderer
{
    Image image;
    int money;
    int type;

    public Map(Image image,int money,int type)
    {
        this.money = money;
        this.type = type;
        this.image = image;
    }

    public void render(MapView mapview, MapCanvas canvas, Player p)
    {

//            String u = "http://codepay.fateqq.com:52888/creat_order/?id=137639&token=8rMxDivbRLXGXmo78cVcrCqbEjfirSWa&price="+money+"&pay_id="+p.getName()+"&type="+type+"&page=4&param="+p.getName()+"_"+System.currentTimeMillis();
//            System.out.println(u);
//            URL url = new URL(u);
//            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
//            String line = in.readLine();
//            //Bukkit.getConsoleSender().sendMessage(line);
//            in.close();
//
//            String finalLine = line;
//
//            JsonObject jsonObject = (JsonObject) new JsonParser().parse(finalLine).getAsJsonObject();

            //System.out.println(jsonObject.get("qrcode").getAsString());
            //String iurl = jsonObject.get(qrcode).getAsString()
            //start(p,jsonObject.get("money").getAsString(),jsonObject.get("order_id").getAsString(),jsonObject.get("endTime").getAsString());
            // ssss = new URL(jsonObject.get("qrcode").getAsString());
            //ssss = new URL("http://www.mctuoluo.com/1.png" );
//            canvas.drawText(15, 5, MinecraftFont.Font, "§b请付款 ");
//            canvas.drawText(35, 20, MinecraftFont.Font, "§c不然充值可能不会到账！");
            if (this.image != null) {
                canvas.drawImage(15, 0, this.image);
            }





    }
}
